package com.ruoyi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.BusWaterAutomonitorevaluateMonthdata;
import com.ruoyi.monitor.service.IBusWaterAutomonitorevaluateMonthdataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自动站月评价Controller
 * 
 * @author maliang
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/monitor/autovaluatemonthdata")
public class BusWaterAutomonitorevaluateMonthdataController extends BaseController
{
    @Autowired
    private IBusWaterAutomonitorevaluateMonthdataService busWaterAutomonitorevaluateMonthdataService;

    /**
     * 查询自动站月评价列表
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        startPage();
        List<BusWaterAutomonitorevaluateMonthdata> list = busWaterAutomonitorevaluateMonthdataService.selectBusWaterAutomonitorevaluateMonthdataList(busWaterAutomonitorevaluateMonthdata);
        return getDataTable(list);
    }

    /**
     * 导出自动站月评价列表
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:export')")
    @Log(title = "自动站月评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        List<BusWaterAutomonitorevaluateMonthdata> list = busWaterAutomonitorevaluateMonthdataService.selectBusWaterAutomonitorevaluateMonthdataList(busWaterAutomonitorevaluateMonthdata);
        ExcelUtil<BusWaterAutomonitorevaluateMonthdata> util = new ExcelUtil<BusWaterAutomonitorevaluateMonthdata>(BusWaterAutomonitorevaluateMonthdata.class);
        util.exportExcel(response, list, "自动站月评价数据");
    }

    /**
     * 获取自动站月评价详细信息
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:query')")
    @GetMapping(value = "/{mn}")
    public AjaxResult getInfo(@PathVariable("mn") String mn)
    {
        return success(busWaterAutomonitorevaluateMonthdataService.selectBusWaterAutomonitorevaluateMonthdataByMn(mn));
    }

    /**
     * 新增自动站月评价
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:add')")
    @Log(title = "自动站月评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        return toAjax(busWaterAutomonitorevaluateMonthdataService.insertBusWaterAutomonitorevaluateMonthdata(busWaterAutomonitorevaluateMonthdata));
    }

    /**
     * 修改自动站月评价
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:edit')")
    @Log(title = "自动站月评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        return toAjax(busWaterAutomonitorevaluateMonthdataService.updateBusWaterAutomonitorevaluateMonthdata(busWaterAutomonitorevaluateMonthdata));
    }

    /**
     * 删除自动站月评价
     */
    //@PreAuthorize("@ss.hasPermi('monitor:autovaluatemonthdata:remove')")
    @Log(title = "自动站月评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mns}")
    public AjaxResult remove(@PathVariable String[] mns)
    {
        return toAjax(busWaterAutomonitorevaluateMonthdataService.deleteBusWaterAutomonitorevaluateMonthdataByMns(mns));
    }

    @GetMapping("/qualityLevelStatis")
    public AjaxResult qualityLevelStatis(String id,String startTime,String endTime){
        return AjaxResult.success(busWaterAutomonitorevaluateMonthdataService.qualityLevelStatis(id,startTime,endTime));
    }

    /**
     * 水质变化趋势
     * @param id
     * @param startTime
     * @param endTime
     * @param items
     * @return
     */
    @GetMapping("/trendStatis")
    public AjaxResult trendStatis(String id,String startTime,String endTime,String items){
        return AjaxResult.success(busWaterAutomonitorevaluateMonthdataService.trendStatis(id,startTime,endTime,items));
    }

    /**
     * 水质级别趋势
     * @param id
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/trendQuality")
    public AjaxResult trendQuality(String id,String startTime,String endTime){
        return AjaxResult.success(busWaterAutomonitorevaluateMonthdataService.trendQuality(id,startTime,endTime));
    }
}
